package com.atguigu.utils;


import com.atguigu.constant.MqConst;
import org.springframework.amqp.rabbit.core.RabbitTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * ScheduledTask
 *
 * @author yangchao
 * @version 开发阶段
 * @description
 * @date 2022/3/7 9:37
 */
@Component
public class ScheduledTask {
    @Autowired
    private RabbitTemplate rabbitTemplate;


    @Async
    @Scheduled(cron = "0 0,30 * * * ? ")  //间隔30分钟
    public void first()   {
        rabbitTemplate.convertAndSend(MqConst.SCAN_SECKILL_EXCHANGE,MqConst.SCAN_SECKILL_ROUTE_KEY,"");
        rabbitTemplate.convertAndSend(MqConst.CLEAR_REDIS_EXCHANGE,MqConst.CLEAR_REDIS_ROUTE_KEY,"");
    }


}